package framework.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPreferencesUtils {
	
	private static final String APP_USER_CACHE = "ZaSheep";

	private static SharedPreferences sp;
	
	public static void init(Context context){
		sp = context.getSharedPreferences(APP_USER_CACHE, Context.MODE_PRIVATE);
	}	
	
	/**
	 * 清除数据
	 * @Title: clearUserInfos
	 * @param
	 * @return void
	 * @throws
	 */
	public static void cleargetSharedPreferences(){
		Editor sysEdit =  sp.edit();
		sysEdit.clear();
		sysEdit.commit();
	}
	/**
	 * 获取Editor
	 */
	public static Editor getgetSharedPreferencesEditor() {
		return sp.edit();
	}
	
	
	/**
	 * 保存数据
	 * @param key
	 * @param value
	 */
	public static void addgetSharedPreferences(String key , String value){
		Editor sysEdit =  sp.edit();
		sysEdit.putString(key, value);
		sysEdit.commit();
	}
	/**
	 * 获取数据
	 */
	public static String getSharedPreferences(String key , String defValue){
		if(sp != null){
			return sp.getString(key, defValue);
		}
		return defValue;
	}
}
